/**==============================================================================
            Copyright (c) 2013 Moritz Hader, Marcel Schrder
            All Rights Reserved.

	@file  ElementObject.java

	@brief Browser intern representation of an Element from the IS

  This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
==============================================================================*/
package de.ibm.dhbw.backing.dataHolding;

import android.util.Log;


/**
 * @author Marcel Schroeder - marcel_schroeder89@hotmail.com
 */
public abstract class ElementObject {
	
	private static float R2D = 57.2957795130823229f;
	//----------- Properties and Constructor -----------//

	private int id;
	private int type;
	private float IS_posX;
	private float IS_posY;
	private Marker marker;
	private float ARB_posX;
	private float ARB_posY;
	private float directionInDegrees;
	private float directionX;
	private float directionY;

	public ElementObject(int id, int type, float IS_posX, float IS_posY, float directionX, float directionY, Marker marker) {
		this.id = id;
		this.type = type;
		this.IS_posX = IS_posX;
		this.IS_posY = IS_posY;
		this.ARB_posX = IS_posX - marker.getIS_posX();
		this.ARB_posY = IS_posY - marker.getIS_posY();
		this.directionX = directionX;
		this.directionY = directionY;
		
		float helper = (float) Math.sqrt(Math.pow(directionX, 2) + Math.pow(directionY, 2));
		
		if(helper > 0) {
			this.directionInDegrees = (float) Math.acos(directionY / helper);
		} else {
			this.directionInDegrees = 0;
		}	
		
		//Convert the RAD to DEG
		this.directionInDegrees = this.directionInDegrees * R2D;
		
		if(directionX > 0){
			this.directionInDegrees = 360 - this.directionInDegrees;
		}
		
		this.marker = marker;
	}
	
	
	//----------- Abstract Methods -----------//

	/**
	 * Generates a String containing the values of the object properties
	 */
	@Override
	public abstract String toString();
	
	@Override
	public abstract boolean equals(Object object);
	
	
	//----------- Simple Getter and Setter -----------//
	
	public int getType() {
		return type;
	}
	public int getId() {
		return id;
	}
	public float getIS_posX() {
		return IS_posX;
	}
	public float getIS_posY() {
		return IS_posY;
	}
	public Marker getMarker() {
		return marker;
	}
	public float getARB_posX() {
		return ARB_posX;
	}
	public float getARB_posY() {
		return ARB_posY;
	}
	public float getDirectionInDegrees() {
		return directionInDegrees;
	}
	public void setIS_posX(float iS_posX) {
		IS_posX = iS_posX;
	}
	public void setIS_posY(float iS_posY) {
		IS_posY = iS_posY;
	}
	public void setARB_posX(float aRB_posX) {
		ARB_posX = aRB_posX;
	}
	public void setARB_posY(float aRB_posY) {
		ARB_posY = aRB_posY;
	}
	public float getDirectionX() {
		return directionX;
	}
	public float getDirectionY() {
		return directionY;
	}
	public void setDirectionInDegrees(float directionInDegrees) {
		this.directionInDegrees = directionInDegrees;
	}
	
}

